package top.dancun.easstudent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import top.dancun.common.utils.PageUtils;
import top.dancun.common.utils.Query;
import top.dancun.easstudent.dao.DormitoryArrangementDao;
import top.dancun.easstudent.entity.DormitoryArrangementEntity;
import top.dancun.easstudent.service.DormitoryArrangementService;

import java.util.Map;
import java.util.Objects;

/**
 * @author dancun
 *
 */
@Service("dormitoryArrangementService")
public class DormitoryArrangementServiceImpl extends ServiceImpl<DormitoryArrangementDao, DormitoryArrangementEntity> implements DormitoryArrangementService {

    /**
     * 查询寝室安排 按学号、寝室查询
     * @param params
     * @return
     */
    @Override
    public PageUtils queryPage(Map<String, Object> pageinfo,Map<String,String > params) {
        IPage<DormitoryArrangementEntity> page =  new Query<DormitoryArrangementEntity>().getPage(pageinfo);
        LambdaQueryWrapper<DormitoryArrangementEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq( StringUtils.isNotBlank(params.get("studentId")),
                        DormitoryArrangementEntity::getStudentId,params.get("studentId"))
                .eq( StringUtils.isNotBlank(params.get("roomId")),
                        DormitoryArrangementEntity::getRoomId,params.get("roomId"));
        page = this.baseMapper.listPage(wrapper,page);



        return new PageUtils(page);
    }

}